<template>
  <div class="app-container">
    <div class="app-container_conter">


    <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="110px" style="display: flex;justify-content: space-between;align-items: flex-end">
     <div>
      <el-form-item label="状态" prop="status">
        <el-select v-model="queryParams.status" placeholder="请选择" clearable size="small">
          <el-option
              v-for="dict in statusOptions"
              :key="dict.dictValue"
              :label="dict.dictLabel"
              :value="dict.dictValue"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="机构列表" prop="sys_id" >
        <el-select v-model="queryParams.sys_id" placeholder="请选择" clearable size="small">
          <el-option
              v-for="dict in  PersonnelList"
              :key="dict.user_id"
              :label="dict.user_name"
              :value="dict.user_id"
          />
        </el-select>
      </el-form-item>
     </div>
      <div style="width: 150px">
      <el-form-item style="width: 150px;text-align: right">
        <el-button type="primary"  size="mini" @click="handleQuery">搜索</el-button>
        <el-button type="info"  size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
      </div>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
            style="background: #0793FF;color:#FFFFFF "
            size="mini"
            @click="handleAdd"
            v-hasPermi="['insurance:productData:add']"
        >新增
        </el-button>
      </el-col>
      <!--      <el-col :span="1.5">-->
      <!--        <el-button-->
      <!--          type="success"-->
      <!--          plain-->
      <!--          icon="el-icon-edit"-->
      <!--          size="mini"-->
      <!--          :disabled="single"-->
      <!--          @click="handleUpdate"-->
      <!--          v-hasPermi="['insurance:productData:edit']"-->
      <!--        >修改</el-button>-->
      <!--      </el-col>-->
      <el-col :span="1.5">
        <el-button
            type="info"
            size="mini"
            :disabled="multiple"
            @click="handleDelete"
            v-hasPermi="['insurance:productData:remove']"
        >删除
        </el-button>
      </el-col>
      <!--      <el-col :span="1.5">-->
      <!--        <el-button-->
      <!--          type="warning"-->
      <!--          plain-->
      <!--          icon="el-icon-download"-->
      <!--          size="mini"-->
      <!--          @click="handleExport"-->
      <!--          v-hasPermi="['insurance:productData:export']"-->
      <!--        >导出</el-button>-->
      <!--      </el-col>-->
<!--      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>-->
    </el-row>

    <el-table v-loading="loading" :data="productDataList"
              style="width: 100%" @selection-change="handleSelectionChange"  :header-cell-style="tableHeaderColor">
      <el-table-column type="selection" width="55" align="center"/>
      <!--      <el-table-column label="数据编号" align="center" prop="id"/>-->
      <el-table-column label="方案名称" align="center" prop="name" min-width="100px"  fixed />
      <!--      :formatter="typeFormat"-->
      <el-table-column label="工种类型" align="center" min-width="100px" prop="type"/>

      <!--      <el-table-column label="特别约定" align="center" prop="agreement" />-->
      <el-table-column label="每人伤亡责任限额(元)" min-width="180px" align="center" prop="casualties">
<!--        <template slot-scope="scope">-->
<!--          {{ scope.row.casualties ? scope.row.casualties + '元' : scope.row.casualties }}-->
<!--        </template>-->
      </el-table-column>
      <el-table-column label="每人医疗费用责任限额(元)" min-width="200px" align="center" prop="medical">
<!--        <template slot-scope="scope">-->
<!--          {{ scope.row.medical ? scope.row.medical + '元' : scope.row.medical }}-->
<!--        </template>-->
      </el-table-column>
      <el-table-column label="基础报价（元）" align="center" min-width="180px" prop="basic_price">
<!--        <template slot-scope="scope">-->
<!--          {{ scope.row.basic_price ? scope.row.basic_price + '元' : scope.row.basic_price }}-->
<!--        </template>-->
      </el-table-column>

      <el-table-column label="法律费用责任限额(元)" min-width="180px" align="center" prop="legal">
<!--        <template slot-scope="scope">-->
<!--          {{ scope.row.legal ? scope.row.legal + '元' : scope.row.legal }}-->
<!--        </template>-->
      </el-table-column>
      <el-table-column label="累计责任限额(元)" min-width="180px" align="center" prop="liability">
<!--        <template slot-scope="scope">-->
<!--          {{ scope.row.liability ? scope.row.liability + '元' : scope.row.liability }}-->
<!--        </template>-->
      </el-table-column>
      <el-table-column label="每次事故每人医疗费用免赔额(元)" min-width="250px" align="center" prop="deductibles">
<!--        <template slot-scope="scope">-->
<!--          {{ scope.row.deductibles ? scope.row.deductibles + '元' : scope.row.deductibles }}-->
<!--        </template>-->
      </el-table-column>
      <el-table-column label="保险费率(%)" min-width="130px" align="center" prop="insurance_rate">
        <template slot-scope="scope">
          {{ scope.row.insurance_rate ? scope.row.insurance_rate + '%' : scope.row.insurance_rate }}
        </template>
      </el-table-column>
      <el-table-column label="保费" align="center" min-width="100px" prop="count_price">
<!--        <template slot-scope="scope">-->
<!--          {{ scope.row.count_price ? scope.row.count_price + '元' : scope.row.count_price }}-->
<!--        </template>-->
      </el-table-column>
      <!--      <el-table-column label="类型" align="center" prop="optional_price">-->
      <!--        <template slot-scope="scope">-->
      <!--          {{scope.row.optional_price ? scope.row.optional_price  + '元' : scope.row.optional_price}}-->
      <!--        </template>-->
      <!--      </el-table-column>-->
      <el-table-column label="保险机构" align="center" min-width="130px" prop="safety_mechanism">
      </el-table-column>
      <el-table-column label="状态" align="center"  prop="status" :formatter="statusFormat"/>
      <el-table-column label="操作" align="center" min-width="150px"   fixed="right" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button
              size="mini"
              type="text"
              @click="handleUpdate(scope.row)"
              v-hasPermi="['insurance:productData:edit']"
          >修改
          </el-button>

          <el-button
              style="color:#FF0000 "
              size="mini"
              type="text"
              @click="handleDelete(scope.row)"
              v-hasPermi="['insurance:productData:remove']"
          >删除
          </el-button>
        </template>
      </el-table-column>
    </el-table>
    </div>
    <pagination
        style="background: transparent"
        v-show="total>0"
        :total="total"
        :page.sync="queryParams.pageNum"
        :limit.sync="queryParams.pageSize"
        @pagination="getList"
    />

    <!-- 添加或修改产品方案对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="1000px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="200px">
        <el-row>
          <el-col>
            <el-form-item label="方案描述">
              <el-input v-model="form.synopsis" placeholder="请输入方案描述" type="textarea" rows="5" maxlength="200"
                        :readonly="true"/>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="工种类型" prop="type">
              <el-input v-model="form.type" placeholder="请输入方案描述" :readonly="true"/>
              <!--              <el-select v-model="form.type" placeholder="请选择对应工种" >-->
              <!--                <el-option-->
              <!--                    v-for="dict in typeOptions"-->
              <!--                    :key="dict.dictValue"-->
              <!--                    :label="dict.dictLabel"-->
              <!--                    :value="dict.dictValue"-->
              <!--                ></el-option>-->
              <!--              </el-select>-->
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="保险机构" prop="safety_mechanism">
              <el-input v-if="isShow" v-model="form.safety_mechanism" placeholder="请选择对应工种"
                        style="width: 250px"></el-input>
              <el-input v-else v-model="form.safety_mechanism" :readonly="true" placeholder="请选择对应工种"
                        style="width: 250px"></el-input>
              <!--              <el-select v-model="form.safety_mechanism" placeholder="请选择对应工种" >-->
              <!--                <el-option-->
              <!--                    v-for="dict in institutions"-->
              <!--                    :key="dict.dictValue"-->
              <!--                    :label="dict.dictLabel"-->
              <!--                    :value="dict.dictValue"-->
              <!--                ></el-option>-->
              <!--              </el-select>-->
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="方案名称" prop="name">
              <el-input v-if="isShow" v-model="form.name" placeholder="请输入方案名称" style="width: 250px"/>
              <el-input v-else v-model="form.name" :readonly="true" placeholder="请输入方案名称" style="width: 250px"/>
            </el-form-item>
          </el-col>
          <el-col :span="12" v-if="user_id==1 || user_id==22">
            <el-form-item label="邮箱" prop="email">
              <el-input v-model="form.email"  placeholder="请输入邮箱" style="width: 250px"/>
            </el-form-item>
          </el-col>
          <el-col :span="12" v-if="form.id != null">
            <el-form-item label="人员列表">
              <el-select v-model="form.sys_id" multiple placeholder="请选择人员列表" @change="getPersonnel">
                <el-option
                    v-for="dict in PersonnelList"
                    :key="dict.user_id"
                    :label="dict.user_name"
                    :value="dict.user_id"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>

        </el-row>
        <el-row>
          <el-form-item label="特别约定" prop="specifically_agreed">
            <el-input v-if="isShow" type="textarea" v-model="form.specifically_agreed" rows="6" placeholder="请输入特别约定"/>
            <el-input v-else type="textarea" :readonly="true" v-model="form.specifically_agreed" rows="6"
                      placeholder="请输入特别约定"/>
          </el-form-item>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="每人伤亡责任限额" prop="casualties">
              <el-input v-model="form.casualties" placeholder="请输入每人伤亡责任限额">
                <template slot="append">元</template>
              </el-input>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="每人医疗费用责任限额" prop="medical">
              <el-input v-model="form.medical" placeholder="请输入每人医疗费用责任限额">
                <template slot="append">元</template>
              </el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="基础报价（元）" prop="basic_price">
              <el-input v-model="form.basic_price" placeholder="请输入基础报价" @input="getBasic">
                <template slot="append">元</template>
              </el-input>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="类型" prop="optional_price">
              <!--              <el-input v-model="form.optional_price" placeholder="请输入可选择">-->
              <!--                <template slot="append">元</template>-->
              <!--              </el-input>-->
              <el-select v-model="form.basic_type" placeholder="请选择类型">
                <el-option
                    v-for="dict in institutions"
                    :key="dict.id"
                    :label="dict.name"
                    :value="dict.id"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <!--          <el-col :span="12">-->
          <!--            <el-form-item label="可选择（元）：10%标准比例、含24小时" prop="optional_price">-->
          <!--              <el-input v-model="form.optional_price" placeholder="请输入可选择">-->
          <!--                <template slot="append">元</template>-->
          <!--              </el-input>-->
          <!--            </el-form-item>-->
          <!--          </el-col>-->
        </el-row>
        <el-row v-if="form.basic_type">
          <el-col :span="12">
            <el-form-item label="" prop="">
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="" prop="optional_price">
              <el-input v-model="form.optional_price" placeholder="请输入金额" @input="getOptionalPrice">
                <template slot="append">元</template>
              </el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="法律费用责任限额" prop="legal">
              <el-input v-model="form.legal" placeholder="请输入可选择">
                <template slot="append">元</template>
              </el-input>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="累计责任限额" prop="liability">
              <el-input v-model="form.liability" placeholder="请输入累计责任限额">
                <template slot="append">元</template>
              </el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="每次事故每人医疗费用免赔额" prop="deductibles">
              <el-input v-model="form.deductibles" placeholder="请输入每次事故每人医疗费用免赔额">
                <template slot="append">元</template>
              </el-input>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="保险费率" prop="insurance_rate">
              <el-input v-model="form.insurance_rate" placeholder="请输入保险费率">
                <template slot="append">%</template>
              </el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="保费" prop="count_price">
              <el-input v-model="form.count_price" placeholder="请输入保费" readonly>
                <template slot="append">元</template>
              </el-input>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="序号" prop="sort">
              <el-input v-model="form.sort" placeholder="请输入序号">
              </el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <div v-if="user_id==1 || user_id==22">
        <el-form-item label="告知书" >
          <div style="">
            <el-upload
                ref="upload"
                action
                :before-upload="beforeUploadForm"
                :http-request="handleUpdateForm"
                :show-file-list="false"
            >
              <div
                  style="width: 100px;height: 100px;line-height: 100px;text-align: center;border: 1px solid #d9d9d9">
                <i class="el-icon-plus avatar-uploader-icon" style="font-size: 30px;color: #d9d9d9"></i>
              </div>
            </el-upload>
            <div  style="display: flex;flex-flow: wrap;align-items: center;">
              {{form.doc}}
              <!--                          <img :src="form.doc" style="margin-right: 5px;margin-bottom: 5px" width="130" height="100px">-->
            </div>
          </div>
        </el-form-item>
        </div>

        <el-form-item label="状态">
          <el-radio-group v-model="form.status">
            <el-radio
                v-for="dict in statusOptions"
                :key="dict.dictValue"
                :label="dict.dictValue"
            >{{ dict.dictLabel }}
            </el-radio>
          </el-radio-group>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button type="info" @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import {
  listProductData,
  getProductData,
  delProductData,
  addProductData,
  updateProductData,
  addProductData1,
  listProductData1,
  exportProductData,
  getType,
  plan_list
} from "@/api/insurance/productData";
import Template from "../../base/template/index";
import {seacond_admin} from "@/api/insurance/productType"
import {uploadFile} from '@/api/policyHolder/ApplicantInformation'

export default {
  name: "ProductData",
  components: {
    Template
  },
  data() {
    return {
      fileList: [],
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      plan_type: null,
      // 产品方案表格数据
      productDataList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 对应工种字典
      typeOptions: [],
      // 0 禁用 1激活字典
      statusOptions: [],
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        status: null,
        user_id: null,
        plan_type: null,
        role_id: null,
        sys_id: null,

      },
      // 表单参数
      form: {
        // productType: {
        synopsis: null
        // }
      },
      // 表单校验
      rules: {
        plan_type: [
          {required: true, message: "pid不能为空", trigger: "blur"},
        ],
        CompanyOrganization: [
          {required: true, message: "请选择保险机构", trigger: "blur"},
        ],
        email:[
          {
            required: false, type: "email", message: "'请输入正确的邮箱", trigger: ["blur"]
          }
        ]
      },
      //保险机构
      institutions: [
        {
          id: '1',
          name: '5%标准比例'
        },
        {
          id: '2',
          name: '10%标准比例'
        }

      ],
      user_id: '',
      role_id: '',
      //  人员列表
      PersonnelList: [],
      isShow: true,//判断选中的值是否是超级管理员或是六骏
      // 是否需要自己信息
      is_self: 1,
    };
  },

  created() {
    this.user_id = JSON.parse(localStorage.getItem('userInfo')).userId;
    this.queryParams.user_id = JSON.parse(localStorage.getItem('userInfo')).userId;
    if (this.user_id == 22 || this.user_id == 1) {
      this.isShow = true;
    } else {
      this.isShow = false;
    }
    // console.log('user_id',this.user_id);
    // console.log('isShow',this.isShow);

    var info = JSON.parse(localStorage.getItem('userInfo'));
    if (info.roles.length != 0) {
      this.role_id = info.roles[0].roleId;
      this.queryParams.role_id = info.roles[0].roleId
    }
    const pid = this.$route.query.product;
    this.plan_type = pid.id
    // console.log('pid', pid)
    this.queryParams.plan_type = pid.id
    this.form.type = pid.type
    this.form.plan_type = pid.id
    this.form.synopsis = pid.synopsis
    this.getList(this.queryParams);

    this.getDicts("common_status").then(res => {
      this.statusOptions = res.data;
    })
    this.getDicts("industry_type").then(res => {
      this.typeOptions = res.data;
      // console.log('typeOptions', this.typeOptions);
    })
    this.PersonnelLists();

  },
  methods: {
    /* 修改表头颜色 */
    tableHeaderColor({ rowIndex }) {
      if (rowIndex === 0) {
        return 'background-color: #304156;color: #fff;font-weight: 400;font-family: Microsoft YaHei;'
      }
    },
    //选择可看人员
    getPersonnel(e) {

      e.forEach(v => {
        if (v == 22 || v == 1) {
          this.isShow = true
        } else {
          this.isShow = false;
        }
        // console.log('isShow', this.isShow)
      })

      // console.log('人员', e)
    },
    //输入基础报价
    getBasic(e) {

      // console.log('e', e)
      // console.log('optional_price',this.form.optional_price)
      if (this.form.optional_price || this.form.optional_price==0) {
        this.form.count_price = parseFloat(this.form.basic_price) + parseFloat(this.form.optional_price)
      }

      // console.log('basic_price', this.form.basic_price)
      // console.log('count_price', this.form.count_price)

    },
    //类型价格
    getOptionalPrice(e) {
      // console.log('form.basic_price',this.form.basic_price)
      if (this.form.basic_price || this.form.basic_price==0) {
        this.form.count_price = parseFloat(this.form.basic_price) + parseFloat(this.form.optional_price)
      }
      // console.log('count_price', this.form.count_price)
    },
    // 对应工种字典翻译
    typeFormat(row, column) {
      return this.selectDictLabel(this.typeOptions, row.type);
    },
    // 0 禁用 1激活字典翻译
    statusFormat(row, column) {
      return this.selectDictLabel(this.statusOptions, row.status);
    },
    /** 查询产品方案列表 */
    getList() {
      this.loading = true;
      // listProductData(this.queryParams).then(response => {
      //   console.log('response产品方案',response)
      //
      //
      // });
      plan_list(this.queryParams).then(response => {
        this.loading = false;
        if (response.code == 1) {
          this.productDataList = response.data.list;
          this.total = response.data.count;
        }
        console.log('产品方案列表', response)
      })
    },
    // 取消按钮
    cancel() {

      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        plan_id: null,//方案id 添加时传空，修改时传对应id
        plan_type: this.form.plan_type,//方案类型id
        // pid: null,
        name: null,//方案名称
        user_id: this.user_id,//当前用户id
        role_id: this.role_id,//  当前用户id
        sys_id: null,//下级管理员id
        safety_mechanism: '',//保险机构
        specifically_agreed: '',//特别约定
        casualties: null,//每人伤亡责任限额
        medical: null,//每人医疗费用责任限额
        basic_price: null,//基础报价
        basic_type: '',//类型
        optional_price: null,//可选择（元）
        // createTime: null,
        // updateTime: null,
        legal: null,//法律费用责任限额
        liability: null,//累计责任限额
        deductibles: null,//每次事故每人医疗费用免赔额
        insurance_rate: null,//保险费率
        type: this.form.type,
        count_price: '',//保费
        // agreement:'',//特别约定
        // CompanyOrganization:'',//保险机构
        // productType: {
        synopsis: this.form.synopsis,
        // },
        sort: null,//序号
        status: "1",
        doc:'',//告知书
        email:'',//邮箱
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      if (this.queryParams.type != null) {
        this.queryParams.pid = null;
      }
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.id)
      this.single = selection.length !== 1
      this.multiple = !selection.length
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.isShow = true;
      for (var i = 0; i < this.typeOptions.length; i++) {
        if (this.typeOptions[i].dictValue == this.form.type) {
          this.form.type = this.typeOptions[i].dictLabel
        }
      }
      this.reset();
      // console.log('form', this.form)
      this.form.pid = this.pid;
      this.open = true;
      this.title = "添加产品方案";
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      for (var i = 0; i < this.typeOptions.length; i++) {
        if (this.typeOptions[i].dictValue == this.form.type) {
          this.form.type = this.typeOptions[i].dictLabel
        }
      }
      this.reset();
      const id = row.id || this.ids
      var obj = {
        plan_id: id,
        plan_type: this.plan_type,
        user_id: this.user_id,
        role_id: this.role_id

      }
      // console.log('obj', obj)
      // listProductData1(obj).then(response=>{
      //   console.log('详情',response)
      // })
      listProductData1(obj).then(response => {
        // console.log('response12', response)
        if(response.code==1){


        this.form = response.data;
        this.form.basic_type=response.data.basic_type.toString()

        if (this.form.safety_mechanism != null) {
          this.form.safety_mechanism = this.form.safety_mechanism.toString();
        }

        this.form.type = this.form.type_name
        this.form.plan_id = this.form.id
        this.form.plan_type = this.form.pid,
            this.form.user_id = this.user_id,//当前用户id
            this.form.role_id = this.role_id,//  当前用户id

            this.open = true;
        this.title = "修改产品方案";
        this.is_self = 0;
        //获取下级权限人员列表
        this.PersonnelLists();
        }
      });
    },
    //获取人员列表
    PersonnelLists() {
      var obj1 = {
        user_id: this.user_id,
        role_id: this.role_id,
        is_self: this.is_self
      }
      seacond_admin(obj1).then(res => {
        if (res.code == 1) {
          this.PersonnelList = res.data;
        }
        // console.log('人员列表', res)

      })
    },
    /** 提交按钮 */
    submitForm() {
      // console.log('form', this.form);
      this.$refs["form"].validate(valid => {
        if (valid) {
          if (this.form.id != null) {
            addProductData1(this.form).then(response => {
              if (response.code == 1) {
                this.msgSuccess(response.msg);
                this.open = false;
                this.getList();
              }

            });
          } else {
            addProductData1(this.form).then(response => {
              if (response.code == 1) {
                this.msgSuccess(response.msg);
                this.open = false;
                this.getList();
              }


            });
          }
        }
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const ids = row.id || this.ids;
      this.$confirm('是否确认删除产品方案编号为"' + ids + '"的数据项?', "警告", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning"
      }).then(function () {
        return delProductData(ids);
      }).then(() => {
        this.getList();
        this.msgSuccess("删除成功");
      })
    },
    /** 导出按钮操作 */
    handleExport() {
      const queryParams = this.queryParams;
      this.$confirm('是否确认导出所有产品方案数据项?', "警告", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning"
      }).then(function () {
        return exportProductData(queryParams);
      }).then(response => {
        this.download(response.msg);
      })
    },
    // 上传告知书显示
    beforeUploadForm(file) {
      // console.log('file12', file)
      const isPng = file.type === 'application/pdf';
      // const isLt2M = file.size / 1024 / 1024 < 2;
      if (!isPng) {
        this.$message.error('上传告知书只能是pdf格式!');
      }
      // if (!isLt2M) {
      //   this.$message.error('上传签章大小不能超过2MB!');
      // }
      return isPng ;
    },
    //上传告知书
    handleUpdateForm(param) {
      console.log('param', param)
      this.fileList.push(param.file);

      let that = this;
      let formData = new FormData();
      this.fileList.forEach(v => {
        formData.append('file', v);
      })
      uploadFile(formData).then(response => {
        // console.log('res图片', response)

        this.form.doc = response.data;
        this.fileList=[];


      })

    }
  }
};
</script>
<style scoped>
.app-container_conter{
  background: #F8FBFF;
  padding:30px;
  border-radius: 10px;
  box-sizing: border-box;
}
</style>
